package sk.marek.barak.data;

import java.util.HashMap;
import java.util.Map;

public class OneDay {
	private String user;
	private Map<String,NewAnnoucement> allNewAnnoucement;
	
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public Map<String, NewAnnoucement> getAllNewAnnoucement() {
		return allNewAnnoucement;
	}
	public void addNewAnnoucement(NewAnnoucement annoucement) throws ItemAlreadyExcits{
		if(allNewAnnoucement==null)
			allNewAnnoucement = new HashMap<String, NewAnnoucement>();
		if(!allNewAnnoucement.containsKey(annoucement.getAnnnoucementDocumentNumber()))
				allNewAnnoucement.put(annoucement.getAnnnoucementDocumentNumber(),annoucement);
		else
			throw new ItemAlreadyExcits("Annoucement number already exits");
			
	}
	public void saveNewAnnoucement(NewAnnoucement annoucement){
		if(allNewAnnoucement.containsKey(annoucement.getAnnnoucementDocumentNumber()))
			allNewAnnoucement.put(annoucement.getAnnnoucementDocumentNumber(),annoucement);
	}
	public NewAnnoucement getNewAnnoucement(String annoucementNumber) throws ItemDoesntExits{
		NewAnnoucement newAnnoucement = allNewAnnoucement.get(annoucementNumber);
		if(newAnnoucement==null){
			throw new ItemDoesntExits("New Annoucement with number "+annoucementNumber+" doesnt exits");
		}
		return newAnnoucement;
			
	}
}
